﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Topcoder
{
    namespace SRM535
    {
        class FoxAndIntegers
        {
            public static int[] get(int AminusB, int BminusC, int AplusB, int BplusC)
            {
                int A2 = AminusB + AplusB;
                int B2 = BminusC + BplusC;
                int B2_ = AplusB - AminusB;
                if (B2 != B2_) return new int[] { }; 
                int C2 = BplusC - BminusC;
                if (((A2 % 2) != 0) || ((B2 % 2) != 0) || ((C2 % 2) != 0)) return new int[] { };
                else return new int[] { A2 / 2, B2 / 2, C2 / 2 };
            }
        }
        class FoxAndGCDLCM
        {
            public static long get(long G, long L)
            {
                if (L % G != 0) return -1;

                long res = -1;
                long ab = L / G;
                // divisors of ab 
                // For each pair (a,b) such that a*b == ab,
                // at least one of the (a,b) will be <= sqrt(ab)
                for (long a = 1; a <= ab / a; a++)
                {
                    if (ab % a == 0)
                    {
                        //try all pairs (a,b) 
                        long b = ab / a;
                        if (gcd(a, b) == 1)
                        { //pair-wise coprime? 
                            long apb = (a + b) * G;
                            if (res == -1)
                            {
                                res = apb;
                            }
                            else
                            {
                                res = Math.Min(res, apb);
                            }
                        }
                    }
                }
                return res;
            }
            static long gcd(long a, long b)
            {
                while (b != 0)
                {
                    long c = b;
                    b = a % b;
                    a = c;
                }
                return a;
            }
        }
    }
}
